package top.chukongxiang.project.base.utils;

import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;

public class ModelUtils {

    /**
     * 校验实体数据
     *
     * @param bindingResult
     */
    public static void check(BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            for (ObjectError error : bindingResult.getAllErrors()) {
                throw new RuntimeException(error.getDefaultMessage());
            }
        }
    }
}
